package prototype.exception;

import com.google.gson.JsonObject;
import prototype.constant.EMessageConst;
import prototype.constant.EObjectType;

/**
 *
 */
public class ObjectFieldException extends AbstractExeption {
	private EObjectType objectType;
	private Integer objectIndex;
	private Long objectId;
	private String fieldName;

	public ObjectFieldException(EMessageConst message, EObjectType objectType, Integer objectIndex, Long objectId, String fieldName) {
		super(message.name());
		this.objectType = objectType;
		this.objectIndex = objectIndex;
		this.objectId = objectId;
		this.fieldName = fieldName;
	}

	public JsonObject toJsonObject() {
		final JsonObject jsonObject = super.toJsonObject();
		jsonObject.addProperty("objectType", objectType.name());
		jsonObject.addProperty("objectIndex", objectIndex);
		jsonObject.addProperty("objectId", objectId);
		jsonObject.addProperty("fieldName", fieldName);
		return jsonObject;
	}
}
